using System;
using System.Web.Mvc;
using EPiServer.Common.Comments;
using EPiServer.Common.Queries;
using EPiServer.Common.Sorting;

namespace JoelAbrahamsson.Web.Controllers
{
    public class LatestCommentsController : Controller
    {
        public ActionResult Index()
        {
            CommentQuery query = new CommentQuery();
            query.Created = new DateTimeCriterion();
            query.OrderBy.Add(new CriterionSortOrder(query.Created, SortingDirection.Descending));
            int totalItems;
            CommentCollection latestComments = QueryHandler.GetQueryResult<Comment, CommentCollection>(query, new TimeSpan(0, 0, 1, 0), 1, 3, out totalItems);
            return View(latestComments);
        }

    }
}
